/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef GEOFENCE_SERVICE_H
#define GEOFENCE_SERVICE_H

#include <memory>
#include <iremote_object.h>
#include <system_ability.h>

#include "geofence_delayed_sp_singleton.h"
#include "geofence_srv_stub.h"
#include "geofence_data_utils.h"
#include "igeofence_callback.h"
#include "igeofence_algorithm_callback.h"
#include "geofence_config.h"
#include "geofence_statemachine.h"
#include "geofence_policy.h"
#include "geofence_manager.h"
#include "geofence_location.h"
#include "geofence_track.h"
#include "geofence_dump.h"

namespace OHOS {
namespace Msdp {
class GeofenceService final : public SystemAbility, public GeofenceSrvStub {
    DECLARE_SYSTEM_ABILITY(GeofenceService)
    DECLARE_DELAYED_SP_SINGLETON(GeofenceService);
public:
    virtual void OnDump() override;
    virtual void OnStart() override;
    virtual void OnStop() override;
    bool IsServiceReady();

    void SubscribePoint(const GeofenceDataUtils::GeofenceType& type,
        const GeofenceDataUtils::PointOptions& pointOptions, const sptr<IgeofenceCallback>& callback) override;
    void UnSubscribePoint(const GeofenceDataUtils::GeofenceType& type,
        const GeofenceDataUtils::PointOptions& pointOptions, const sptr<IgeofenceCallback>& callback) override;
    void SubscribePoi(const GeofenceDataUtils::GeofenceType& type,
        const GeofenceDataUtils::PoiOptions& poiOptions, const sptr<IgeofenceCallback>& callback) override;
    void UnSubscribePoi(const GeofenceDataUtils::GeofenceType& type,
        const GeofenceDataUtils::PoiOptions& poiOptions, const sptr<IgeofenceCallback>& callback) override;
    bool SetFoolproofTactics(const GeofenceDataUtils::GeofenceType& type, double minuteTime) override;

    int32_t Dump(int fd, const std::vector<std::u16string> &args) override;

    std::shared_ptr<GeofenceConfig> GetGeofenceConfig();
    std::shared_ptr<GeofencePolicy> GetGeofencePolicy();
    std::shared_ptr<GeofenceManager> GetGeofenceManager();
    std::shared_ptr<GeofenceStateMachine> GetGeofenceStateMachine();
    std::shared_ptr<GeofenceLocation> GetGeofenceLocation();
    std::shared_ptr<GeofenceTrack> GetGeofenceTrack();
private:
    bool Init();
    bool ready_ = false;
    std::shared_ptr<GeofenceConfig> geofenceConfig_;
    std::shared_ptr<GeofencePolicy> geofencePolicy_;
    std::shared_ptr<GeofenceManager> geofenceManager_;
    std::shared_ptr<GeofenceStateMachine> geofenceStateMachine_;
    std::shared_ptr<GeofenceLocation> geofenceLocation_;
    std::shared_ptr<GeofenceTrack> geofenceTrack_;

};
} // namespace Msdp
} // namespace OHOS
#endif // GEOFENCE_SERVICE_H
